package com.smile.api;

import com.smile.commons.page.R;
import com.smile.model.request.DeleteFileRequest;
import com.smile.model.request.PutFileRequest;
import com.smile.model.response.PutFileResponse;
import feign.RequestLine;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

@FeignClient(value = "smile-plus-standalone-oss",
        contextId = "oss",
        path = "/api/oss"
)
public interface OssApi {

    @PostMapping(value = "/oss/putFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R<PutFileResponse> putFile(@RequestParam String path, @RequestParam String fileName, @RequestPart(value = "file", required = false) MultipartFile file) throws IOException;

    @PostMapping(value = "/oss/deleteFile", consumes = MediaType.APPLICATION_JSON_VALUE)
    R deleteFile(@RequestBody DeleteFileRequest request) throws IOException;

    @PostMapping(value = "/oss/putPcmFile", produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}, consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.APPLICATION_JSON_VALUE})
    R<PutFileResponse> putPcmFile(@RequestParam String path, @RequestPart(value = "file", required = false) MultipartFile file) throws IOException;

    @PostMapping(value = "/minio/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R<PutFileResponse> upload(@RequestParam("file") MultipartFile file) throws IOException;

    @PostMapping(value = "/minio/uploadZip")
    R<Map> uploadZip(@RequestParam("file") MultipartFile file) throws IOException;


    @PostMapping(value = "/oss/putkmlFile", produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}, consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.APPLICATION_JSON_VALUE})
    R<PutFileResponse> putkmlFile(@RequestParam String fileName, @RequestPart MultipartFile fileStream) throws IOException;
}
